package com.china08.yxyapi.api.manage.tec.office.moments;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.mg.moments.YxyMomentsRepository;
import com.china08.yxyapi.util.YxUserPointsUtilV3;

/**
 * 班级圈--全部/我的发布--删除班级圈
 * 
 * @author LiuWeidong
 *
 */
@CrossOrigin
@RestController
public class MomentsDelController extends YxyApiBaseController {

    @Autowired
    private YxyMomentsRepository yxyMomentsRepository;

    @Autowired
    private YxUserPointsUtilV3 yxUserPointsUtilV3;

    @RequestMapping(value = "/api_yw/mapi_ywanagew/tec/office/student/srh/release/del/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel precess(HttpServletRequest request,
            HttpServletResponse response, RespModel respModel,
            @PathVariable("id") String id) {
        String userId = getProfile(request, response).getId();
        yxyMomentsRepository.deleteByIdAndSenderId(id, userId);

        respModel = new RespModel();
        respModel.setMessage("删除成功");
        yxUserPointsUtilV3.delClassMessage(userId);
        return respModel;
    }

    protected static class RespModel extends YxyApiRespModel {
    }
}
